<div class="row actions">
    <div class="col-md-12">
        <div class="pull-left">
            <a  class="btn btn-primary"
                ng-if="user.hasPermission($state.name.split('.')[0],'create')"
                ng-click="openUploadCertsModal()">
                <i class="mdi mdi-plus"></i>
                Add Certificate
            </a>
        </div>
        <list-search
                class="pull-right"
                data-filters="filters"
                data-options="itemsPerPageOptions"
                data-items="itemsPerPage"
        ></list-search>
    </div>
</div>

<konga-loader ng-if="loading && !items.length"></konga-loader>
<div class="row" ng-if="!loading || items.length">
    <div class="col-md-12">
        <div class="table-responsive">
            <table class="table table-striped table-hover">
                <tr>
                    <th width="{{item.width}}" class="text-nowrap"
                        data-ng-repeat="item in titleItems | filter:titleFilter"
                    >
                        <a
                                data-ng-show="item.column"
                                class="clickable"
                                data-ng-click="changeSort(item)"
                                data-ng-bind-html="item.title.toUpperCase()"
                        ></a>
                        <span
                                data-ng-show="!item.column"
                                data-ng-bind-html="item.title.toUpperCase()"
                        ></span>

                        <i class="mdi"
                           data-ng-show="sort.column == item.column"
                           data-ng-class="{'mdi-chevron-down': !sort.direction, 'mdi-chevron-up': sort.direction}"
                        ></i>
                    </th>
                    <th width="1" ng-if="user.hasPermission($state.name.split('.')[0],'update')"></th>
                    <th width="1" ng-if="user.hasPermission($state.name.split('.')[0],'delete')"></th>
                </tr>
                <tr
                        dir-paginate="item in items.data | orderBy:sort.column:sort.direction | filter : filters.searchWord | itemsPerPage: itemsPerPage">

                    <td>{{item.id}}</td>
                    <td>
                        <span class="badge badge-tag badge-success badge-inverse" ng-repeat="tag in item.tags">
                            <i class="mdi mdi-tag"></i>&nbsp;
                            {{tag}}
                        </span>
                    </td>
                    <td>
                        <span class="badge" style="margin-right: 3px;margin-bottom: 3px" ng-repeat="sni in item.snis">
                            {{sni}}
                        </span>
                    </td>
                    <td>{{moment(item.created_at * 1000).format("MMM DD YYYY @HH:mm")}}</td>
                    <td ng-if="user.hasPermission($state.name.split('.')[0],'update')">
                        <button type="button" ng-click="openUploadCertsModal(item)" class="btn btn-primary btn-link">
                            <i class="mdi mdi-information-outline"></i>
                            details
                        </button>
                    </td>
                    <td ng-if="user.hasPermission($state.name.split('.')[0],'delete')">
                        <button type="button" ng-click="deleteItem($index,item)" class="btn btn-danger btn-link">
                            <i class="mdi mdi-delete"></i>
                            Delete
                        </button>
                    </td>
                </tr>
                <tr data-ng-if="(items.data == {} || !items.data.length) && !loading">
                    <td colspan="100%" class="text-center text-muted">
                        <em>No data found...</em>
                    </td>
                </tr>
                <tr data-ng-if="loading">
                    <td colspan="100%" class="text-center text-muted">
                        <em>Loading items...</em>
                    </td>
                </tr>
            </table>
        </div>
        <dir-pagination-controls class="pull-right"></dir-pagination-controls>
    </div>
</div>
